﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<RankingSejmowy.UI.Core.ViewModels.Import.IndexViewModel>" %>
<%@ Import Namespace="RankingSejmowy.Common.Localization" %>
<%@ Import Namespace="RankingSejmowy.UI.Core" %>
<%@ Import Namespace="RankingSejmowy.UI.Core.Extensions" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Import</h2>
    <p>
        <label><%= AppStrings.Cadence %></label>
        <span><%= Html.Encode(Model.Cadence) %></span>
    </p>
    <p>
        <label><%= AppStrings.LastMeetingNumber %></label>
        <span><%= Html.Encode(Model.LastMeetingNumber) %></span>
    </p>
    <p>
        <label><%= AppStrings.ActualVotingNumber %></label>
        <span id="actualVoting"><img src="../../Content/Images/ajax-loader.gif" /></span>
    </p>

    <% using(Html.BeginForm()) {%>
        <%= Html.Hidden("LastMeetingNumber", Model.LastMeetingNumber)%>
        <ul id="meetingList"></ul>
    <% } %>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">

    <script id="meetingTmpl" type="text/html">
        {{each Meetings}}
            <li><span><%= AppStrings.MeetingNr%>&nbsp;${MeetingNum}</span>&nbsp;<span>${Date}</span></li>
        {{/each}}
        {{tmpl "#meetingCmdTmpl"}}
    </script>

    <script id="meetingCmdTmpl" type="text/html">
        <li><label></label><input name="meetingsToImport"/></li>
        <li><input type="submit" value="<%= AppStrings.Import %>"/></li>
    </script>

    <script type="text/javascript">

        $(function () {
            $.post("/aktualne-glosowanie/6?t=" + +(new Date()).getTime(), function (data) {
                if (!data.AreNewMeetings) {
                    $("#actualVoting").text(Localization.NoMeetingsToImport);
                }
                else {
                    $("#meetingTmpl").tmpl(data).appendTo("#meetingList");
                }

                $("#actualVoting").text("");
            });
        });

    </script>
</asp:Content>